<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('保险金统计列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>岗位属性：</label>
                                <select name="postType" th:with="type=${@dict.getType('post_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>编制情况：</label>
                                <select name="workDuty" th:with="type=${@dict.getType('basic_work_duty')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>统计时间：</label>
                                <input type="text" class="time-input" id="benefitMonth" data-type="month" name="benefitMonth" th:value="${benefitMonth}"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="query()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a id="clockBtn" class="btn btn-success" onclick="clock()" shiro:hasPermission="report:benefit:clock">
                    <i class="fa fa-download"></i> 数据锁定
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-table-export-js" />
    <th:block th:include="include :: bootstrap-table-fixed-columns-js" />
    <script th:inline="javascript">
        var prefix = ctx + "report/benefit";

        var posts = [[${@dict.getType('post_type')}]];
        var workDutys = [[${@dict.getType('basic_work_duty')}]];

        function query() {
            checkClock();
            $.table.search();
        }

        $(function () {
            var options = {
                url: prefix + "/list",
                modalName: "保险金报表",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                showExport: true,
                exportDataType: 'all',
                exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'], // 导出的文件类型
                exportFooter: true,
                exportOptions: {
                    fileName: $("#benefitMonth").val() + '保险金统计报表',    // 文件名称设置
                    mso: {
                        worksheetName: '保险金统计报表',
                        //修复导出数字不显示为科学计数法
                        onMsoNumberFormat: function (cell, row, col) {
                            return !isNaN($(cell).text())?'0\\.00':'';
                        }
                    }
                },
                fixedColumns: true,
                fixedNumber: 5,
                columns: [
                    [{
                        field: 'postType',
                        title: '岗位属性',
                        rowspan : 2,
                        sortable: true,
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(posts, value);
                        }
                    },
                    {
                        field: 'workDuty',
                        title: '编制情况',
                        rowspan : 2,
                        sortable: true,
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(workDutys, value);
                        }
                    },
                    {
                        title : '养老保险',
                        align : 'center',
                        valign : 'center',
                        colspan : 2
                    },
                    {
                        title : '医疗保险',
                        align : 'center',
                        valign : 'center',
                        colspan : 2
                    },
                    {
                        title : '失业保险',
                        align : 'center',
                        valign : 'center',
                        colspan : 2
                    },
                    {
                        field: "e",
                        title : '工伤保险',
                        align : 'center',
                        valign : 'center',
                        rowspan: 2
                    },
                    {
                        title : '年金',
                        align : 'center',
                        valign : 'center',
                        colspan : 2
                    },
                    {
                        field: 'g',
                        title : '公务员医疗',
                        align : 'center',
                        valign : 'center',
                        rowspan : 2
                    },
                    {
                        title : '公积金',
                        align : 'center',
                        valign : 'center',
                        colspan : 2
                    },
                    {
                        field: 'k',
                        title : '滞纳金',
                        align : 'center',
                        valign : 'center',
                        rowspan : 2
                    }],
                    [{
                        field: 'a1',
                        title: '单位'
                    },
                    {
                        field: 'a2',
                        title: '个人'
                    },
                    {
                        field: 'd1',
                        title: '单位'
                    },
                    {
                        field: 'd2',
                        title: '个人'
                    },
                    {
                        field: 'c1',
                        title: '单位'
                    },
                    {
                        field: 'c2',
                        title: '个人'
                    },
                    {
                        field: 'f1',
                        title: '单位'
                    },
                    {
                        field: 'f2',
                        title: '个人'
                    },
                    {
                        field: 'j1',
                        title: '单位'
                    },
                    {
                        field: 'j2',
                        title: '个人'
                    }]
                ]
            };
            $.table.init(options);
        });

        function checkClock() {
            var reportMonth = $("#benefitMonth").val();
            $.ajax({
                type: "post",
                url: prefix + "/checkClock",
                dataType: "json",
                data: {"reportMonth" : reportMonth},
                success: function(r) {
                    if (r.code == web_status.FAIL) {
                        $("#clockBtn").attr('disabled', true);
                    } else {
                        $("#clockBtn").removeAttr('disabled');
                    }
                    $.modal.closeLoading();
                }
            });
        }

        function clock() {
            var reportMonth = $("#benefitMonth").val();
            $.modal.confirm("确定要锁定当前保险金数据吗？", function() {
                $.operate.post(prefix + "/clockReport", { "reportMonth": reportMonth });
            })
        }
    </script>
</body>
</html>